package com.braintreepayments.cardform.view;

import ohos.agp.components.AttrSet;
import ohos.agp.components.Checkbox;
import ohos.app.Context;

/**
 * Sets an initial CheckBox checked state that is overwritten when restoring this view.
 */
public class InitialValueCheckBox extends Checkbox {

    private static final String EXTRA_SUPER_STATE = "com.braintreepayments.cardform.view.InitialValueCheckBox.EXTRA_SUPER_STATE";
    private static final String EXTRA_CHECKED_VALUE = "com.braintreepayments.cardform.view.InitialValueCheckBox.EXTRA_CHECKED_VALUE";

    private boolean mRestored;

    public InitialValueCheckBox(Context context) {
        super(context);
    }

    public InitialValueCheckBox(Context context, AttrSet attrs) {
        super(context, attrs);
    }

    public InitialValueCheckBox(Context context, AttrSet attrs, String defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    /**
     * Sets the initial value for the CheckBox checked state.
     *
     * @param checked the CheckBox checked state.
     */
    public void setInitiallyChecked(boolean checked) {
        if (!mRestored) {
            setChecked(checked);
        }
    }
}
